Telegram Group & Telegram Channel
Одноразовый метод в классе

В случае, если вдруг понадобится в классе функция, которая будет использоваться всего один раз, после чего будет использоваться другая функция, можно воспользоваться приемом на картинке.

Последней строчкой метода call является переопределение самого этого метода на другой, а именно normal_call. Таким образом, изначальный код call будет исполнен только один раз.

Подобный прием будет полезен в тех случаях, когда при самом первом вызове метода в классе требуются выполнить одноразовые действия, которые в дальнейшем не нужны.

#классы #функции



tg-me.com/python_academy/906
Create:
Last Update:

Одноразовый метод в классе

В случае, если вдруг понадобится в классе функция, которая будет использоваться всего один раз, после чего будет использоваться другая функция, можно воспользоваться приемом на картинке.

Последней строчкой метода call является переопределение самого этого метода на другой, а именно normal_call. Таким образом, изначальный код call будет исполнен только один раз.

Подобный прием будет полезен в тех случаях, когда при самом первом вызове метода в классе требуются выполнить одноразовые действия, которые в дальнейшем не нужны.

#классы #функции

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/906

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

NEWS: Telegram supports Facetime video calls NOW!

Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.

Python Academy from jp


Telegram Python Academy
FROM USA